<?php

class weatherController extends base
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 所有城市列表
     */
    public function dogetcities()
    {
        $this->result['result'] = $this->load('weather')->getAllCity();
    }
    /**
     * 获取城市天气信息
     */
    public function dogetWeather()
    {
        // 获取参数
        $city_id = common::request('city_id', 'G');

        // 2.5.0 添加经纬度
        $lat = common::request('lat', 'G', '');  // 纬度
        $lng = common::request('lng', 'G', '');  // 经度

        $uid = $this->uid;

        // 记录用户坐标
        if($lat && $lng && $uid)
        {
            $this->load('user')->setCoordinate($uid, $lat, $lng);
        }

        $info = $city_id ? $this->load('weather')->getWeatherInfo($city_id) : (object)Array();

        // 兼容安卓客户端
        if(!is_object($info) && isset($info['windInfo']))
        {
            $info['windinfo'] = $info['windInfo'];
        }

        $this->result['result'] = $info;
    }
}